--[[ 编码: WMS-16-21 名称: 盘点计划-刷新计划盘点容器货位信息 作者:HAN 日期:2025-1-29 级别:固定 (说明本段代码在项目中不太会变化) 函数: ResetContainerLocInfo 功能: 根据计划盘点号找出 CP_Count_Container 中 N_B_STATE = 0 的容器 获取容器的位置信息,设置 S_LOC_CODE 更改记录: --]] wms_wh = require( "wms_wh" ) function ResetContainerLocInfo ( strLuaDEID ) local nRet, strRetInfo, n local count_plan nRet, count_plan = m3.GetSysCurEditDataObj( strLuaDEID, "Count_Plan" ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..count_plan ) end -- 如果不是执行中的 盘点计划 不做这个设置 if ( count_plan.b_state ~= 2 ) then lua.Warning( strLuaDEID, debug.getinfo(1), "盘点计划编号 = '"..count_plan.cp_no.."' 目前的状态不能做计划盘点容器货位定制!" ) return end -- 获取容器所在的货位 local strCondition, strClsID local strOrder = '' strCondition = "S_CNTR_CODE IN ( Select S_CNTR_CODE From TN_CP_Count_Container Where (N_B_STATE = 0 or N_B_STATE = 1) AND" strCondition = strCondition.." S_CP_NO ='"..count_plan.cp_no.."')" -- 多页查询 nRet, strRetInfo = mobox.queryDataObjAttr2( strLuaDEID, "Loc_Container", strCondition, strOrder, 100, "S_LOC_CODE","S_CNTR_CODE" ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "queryDataObjAttr2: "..strRetInfo) end if ( strRetInfo == '' ) then return end local success local queryInfo success, queryInfo = pcall( json.decode, strRetInfo ) if ( success == false ) then lua.Error( strLuaDEID, debug.getinfo(1), "queryDataObjAttr2 返回结果啊非法的JSON格式!" ) end local queryID = queryInfo.queryID local nPageCount = queryInfo.pageCount local nPage = 1 local dataSet = queryInfo.dataSet -- 查询出来的数据集 local strSetAttr, loc_code, cntr_code local loc while (nPage <= nPageCount) do for n = 1, #dataSet do loc_code = dataSet[n].attrs[1].value cntr_code = dataSet[n].attrs[2].value nRet, loc = wms_wh.GetLocInfo( loc_code ) if ( nRet == 0 ) then strCondition = "S_CP_NO = '"..count_plan.cp_no.."' AND S_CNTR_CODE = '"..cntr_code.."'" strSetAttr = "S_LOC_CODE = '"..loc.code.."', S_WH_CODE = '"..loc.wh_code.."'".. ", S_AREA_CODE = '"..loc.area_code.."', N_AISLE = "..loc.aisle..", S_AISLE_CODE = '"..loc.aisle_code.."'".. ", N_ROW = "..loc.row..", N_COL = "..loc.col..", N_LAYER = "..loc.layer nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "CP_Count_Container", strCondition, strSetAttr ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "updateDataAttrByCondition失败"..strRetInfo ) end end end nPage = nPage + 1 if ( nPage <= nPageCount ) then -- 取下一页 nRet, strRetInfo = mobox.queryDataObjAttr2( queryID, nPage) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "queryDataObjAttr2失败! nPage="..nPage.." "..strRetInfo ) end queryInfo = json.decode(strRetInfo) dataSet = queryInfo.dataSet end end end